]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
appDisplay: Only reload frequently used data when mapping the frequent view
authorJasper St. Pierre <jstpierre@mecheye.net>
Tue, 28 Jan 2014 16:06:21 +0000 (11:06 -0500)
committerJasper St. Pierre <jstpierre@mecheye.net>
Wed, 29 Jan 2014 19:02:26 +0000 (14:02 -0500)
If the user mostly uses the All Apps view and uses it as his default view,
we shouldn't reload frequent data after a timeout. Simply do it when the
view is mapped.

https://bugzilla.gnome.org/show_bug.cgi?id=723179

js/ui/appDisplay.js

index 921d83b071680ff7a579bf136ba0bc0b148769f3..21cf56be644207427c5a3d145f5d995ba3f79054 100644 (file)
@@ -561,17 +561,18 @@ const FrequentView = new Lang.Class({
         this._noFrequentAppsLabel.hide();
 
         this._usage = Shell.AppUsage.get_default();
+
+        this.actor.connect('notify::mapped', Lang.bind(this, function() {
+            if (this.actor.mapped)
+                this._redisplay();
+        }));
     },
 
     hasUsefulData: function() {
         return this._usage.get_most_used("").length >= MIN_FREQUENT_APPS_COUNT;
     },
 
-    removeAll: function() {
-        this._grid.destroyAll();
-    },
-
-    loadApps: function() {
+    _loadApps: function() {
         let mostUsed = this._usage.get_most_used ("");
         let hasUsefulData = this.hasUsefulData();
         this._noFrequentAppsLabel.visible = !hasUsefulData;
@@ -586,6 +587,11 @@ const FrequentView = new Lang.Class({
         }
     },
 
+    _redisplay: function() {
+        this.removeAll();
+        this._loadApps();
+    },
+
     // Called before allocation to calculate dynamic spacing
     adaptToSize: function(width, height) {
         let box = new Clutter.ActorBox();
@@ -652,9 +658,6 @@ const AppDisplay = new Lang.Class({
         Shell.AppSystem.get_default().connect('installed-changed', Lang.bind(this, function() {
             Main.queueDeferredWork(this._allAppsWorkId);
         }));
-        Main.overview.connect('showing', Lang.bind(this, function() {
-            Main.queueDeferredWork(this._frequentAppsWorkId);
-        }));
         this._folderSettings = new Gio.Settings({ schema: 'org.gnome.desktop.app-folders' });
         this._folderSettings.connect('changed::folder-children', Lang.bind(this, function() {
             Main.queueDeferredWork(this._allAppsWorkId);
@@ -720,7 +723,6 @@ const AppDisplay = new Lang.Class({
         this._viewStack.add_actor(this._focusDummy);
 
         this._allAppsWorkId = Main.initializeDeferredWork(this.actor, Lang.bind(this, this._redisplayAllApps));
-        this._frequentAppsWorkId = Main.initializeDeferredWork(this.actor, Lang.bind(this, this._redisplayFrequentApps));
     },
 
     _showView: function(activeIndex) {
@@ -754,13 +756,6 @@ const AppDisplay = new Lang.Class({
             this._showView(Views.ALL);
     },
 
-    _redisplayFrequentApps: function() {
-        let view = this._views[Views.FREQUENT].view;
-
-        view.removeAll();
-        view.loadApps();
-    },
-
     _redisplayAllApps: function() {
         let view = this._views[Views.ALL].view;
         view.removeAll();